<?php if(!defined('BASEPATH')) exit("Sorry, what you're looking not found.");
class C_info extends Nvl_Controller{
    function __construct(){
        parent::__construct();
        session_start();
		$this->__checkSession();
        $this->load->model('m_info');
    }

    function index(){
        $this->load->view('pages/v_info');
    }
	
	function get_info(){
		echo $this->m_info->get_info();
	}
	
	function save(){
		$status = "";
		$msg = "";
		$filename = "";
		$file_element_name = "info_logo";
		
		$config['upload_path'] = 'files/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = 1024 * 2;
        $config['encrypt_name'] = TRUE;
        $this->load->library('upload', $config);
		if (!$this->upload->do_upload($file_element_name)){
            $status = 'error';
            $msg = $this->upload->display_errors('', '');
        } else {
            $data_logo = $this->upload->data();
			$filename = $data_logo["file_name"];
        }
		
		$params = json_decode($this->input->post('params'));
		extract(get_object_vars($params));
		$data = array(
			"info_nama"=>$form_data->info_nama,
			"info_alamat"=>$form_data->info_alamat,
			"info_kota"=>$form_data->info_kota,
			"info_telp"=>$form_data->info_telp,
			"info_fax"=>$form_data->info_fax,
			"info_email"=>$form_data->info_email,
			"info_logo"=>$filename
		);
		$result = $this->m_info->__save($data, $info_id);
		echo $result;
	}
}